import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import About from '../views/About.vue'
// import contant from '../views/contant.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    // component: Home,
    //命名视图
    components:{
      default:Home,
      view2:About,
    }
  },
  {
    path: '/about',
    name: 'About',
    component:() =>import('../views/About.vue'),//懒加载 
    beforeEnter: (to, from, next) => {
      console.log('路由独享守卫to==>', to),
      console.log('路由独享守卫from===>',from);
      next();
    }
  },
  { 
    path:'/contant/:id',
    name:'contant',
    component:()=>import('../views/contant.vue')
  },
  {
    path:'/user',
    name:'user',
    component:() => import('../views/user.vue'),
    redirect:{name:'lesson'},
   
    children:[
      {
        path:'lesson',
        name:'lesson',
        component:() => import('../views/lesson.vue')
      },
      {
        path:'email',
        name:'email',
        component:() => import('../views/email.vue')
      },
      {
        path:'set',
        name:'set',
        component:() => import('../views/set.vue'),
        meta:{
          isQuit:false
        },
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
